clear
*import delimited "/Users/melamend.9la/Desktop/School/Research/InPrep/Reciprocity ABM/Experiment Stuff/forstata.csv", encoding(ISO-8859-1)
import delimited "/Users/melamend.9la/Desktop/School/Research/UnderReview/Reciprocity ABM/Experiment Stuff/forstata.csv", encoding(ISO-8859-1)
replace male = male-.5
* 0 is white, 1 is other, 2 is hispanic, 3 is asian, and 4 is black
* men are less prosocial than women
destring drsim grsim1 grsim2 irsim1 irsim2, force replace
drop if remove==1

gen rr = ir
drop ir
gen ir = a
drop a
gen rrsim1 = irsim1
gen rrsim2 = irsim2
drop irsim1 irsim2
gen rrsimsum = rrsim1+rrsim2
gen grsimsum = grsim1+grsim2



mixed giving i.race male age || nesting:



*** DR First mover (.507 (.088))
gen drfirst = .
recode drfirst (.=0) if dr==0
recode drfirst (.=1) if dr==1
mixed giving i.drfirst male i.gr i.rr i.ir || nesting:
margins i.drfirst, atmeans
* This can be said
* No interactions with other forms of reciprocity
mixed giving i.drfirst##i.gr i.drfirst##i.rr i.drfirst##i.ir male  || nesting:
estimates store block1
mixed giving i.drfirst i.gr i.drfirst##i.rr i.drfirst##i.ir male  || nesting:
estimates store block2
lrtest block1 block2
mixed giving i.drfirst i.gr i.drfirst##i.rr i.drfirst##i.ir male  || nesting:
estimates store block1
mixed giving i.drfirst i.gr i.rr i.drfirst##i.ir male  || nesting:
estimates store block2
lrtest block1 block2
mixed giving i.drfirst i.gr i.rr i.drfirst##i.ir male  || nesting:
estimates store block1
mixed giving i.drfirst i.gr i.rr i.ir male  || nesting:
estimates store block2
lrtest block1 block2


*** DR Second mover (.339 (.021)) for each unit alter gave ego
gen drsecond = .
recode drsecond (.=0) if dr==0
recode drsecond (.=1) if dr==2
mixed giving c.drsim##i.drsecond male i.gr i.rr i.ir || nesting:
* Control is 4.94, .103
margins drsecond, at(drsim=(0(1)10)) atmeans

* No significant interactions
mixed giving c.drsim##i.gr c.drsim##i.rr c.drsim##i.ir male  if drsecond==1|| nesting:
estimates store block1
mixed giving c.drsim i.gr c.drsim##i.rr c.drsim##i.ir male  if drsecond==1|| nesting:
estimates store block2
lrtest block1 block2
mixed giving c.drsim i.gr c.drsim##i.rr c.drsim##i.ir male  if drsecond==1|| nesting:
estimates store block1
mixed giving c.drsim i.gr i.rr c.drsim##i.ir male  if drsecond==1|| nesting:
estimates store block2
lrtest block1 block2
mixed giving c.drsim i.gr i.rr c.drsim##i.ir male  if drsecond==1|| nesting:
estimates store block1
mixed giving c.drsim i.gr i.rr i.ir male  if drsecond==1|| nesting:
estimates store block2
lrtest block1 block2

sum giving if drfirst==0 & drsecond==0
sum giving if dr==0
sum giving if dr==1
sum giving if dr==2

sum giving if gr==0
sum giving if gr==1
sum giving if gr==2

sum giving if ir==0
sum giving if ir==1
sum giving if ir==2

sum giving if rr==0
sum giving if rr==1
sum giving if rr==2


*** IR (.405 (.090)) if 1 alter; (.521 (.090)) if 2 alters
mixed giving male i.gr i.rr i.ir i.dr || nesting:
*
mixed giving male i.ir##i.gr i.ir##i.rr  i.ir##i.dr || nesting:
estimates store block1
mixed giving male i.ir i.gr i.ir##i.rr  i.ir##i.dr || nesting:
estimates store block2
lrtest block1 block2
mixed giving male i.ir i.gr i.ir##i.rr  i.ir##i.dr || nesting:
estimates store block1
mixed giving male i.ir i.gr i.rr  i.ir##i.dr || nesting:
estimates store block2
lrtest block1 block2
mixed giving male i.ir i.gr i.rr  i.ir##i.dr || nesting:
estimates store block1
mixed giving male i.ir i.gr i.rr  i.dr || nesting:
estimates store block2
lrtest block1 block2
* Preferred model: IR gets stronger when DR already occured
mixed giving male i.ir i.gr i.rr  i.ir##i.dr || nesting:
margins ir##dr, atmeans
marginsplot
* Spaghetti, needs to be plotted in R


*** GR
gen groth = .
replace groth = grsim1 if gr==1
replace groth = (grsim1+grsim2)/2 if gr==2
* Each unit from others, on average (.132 (.022))
mixed giving male  c.groth i.rr i.ir i.dr || nesting:
*
mixed giving male  c.groth##i.rr c.groth##i.ir c.groth##i.dr || nesting:
estimates store block1
mixed giving male  c.groth##i.rr c.groth##i.ir i.dr || nesting:
estimates store block2
lrtest block1 block2
mixed giving male  c.groth##i.rr c.groth##i.ir i.dr || nesting:
estimates store block1
mixed giving male  c.groth##i.rr i.ir i.dr || nesting:
estimates store block2
lrtest block1 block2
mixed giving male  c.groth##i.rr i.ir i.dr || nesting:
estimates store block1
mixed giving male  c.groth i.rr i.ir i.dr || nesting:
estimates store block2
lrtest block1 block2
* Preferred model: GR is weaker in the presence of RR
mixed giving male  c.groth##i.rr i.ir i.dr || nesting:
margins rr, at(groth=(0(1)10)) atmeans
marginsplot
* Whether there was 1 or 2 others to GR
gen grtwo = .
recode grtwo (.=0) if gr==1
recode grtwo (.=1) if gr==2
gen groth2 = .
replace groth2 = grsim1 if gr==1
replace groth2 = (grsim1+grsim2) if gr==2
****************************************************************************************************************
****************************************************************************************************************
*** Need to add this to the results...
mixed giving male  c.groth2##i.grtwo i.rr i.ir i.dr || nesting:
mixed giving male  c.groth2##c.groth2 i.rr i.ir i.dr || nesting:


* RR
gen rroth = .
replace rroth = rrsim1 if rr==1
replace rroth = (rrsim1+rrsim2)/2 if rr==2
* Each unit other gave (.175 (.022))
mixed giving male  c.rroth i.gr i.ir i.dr || nesting:
*
mixed giving male  c.rroth##i.gr c.rroth##i.ir c.rroth##i.dr || nesting:
estimates store block1
mixed giving male  c.rroth i.gr c.rroth##i.ir c.rroth##i.dr || nesting:
estimates store block2
lrtest block1 block2
mixed giving male  c.rroth i.gr c.rroth##i.ir c.rroth##i.dr || nesting:
estimates store block1
mixed giving male  c.rroth i.gr i.ir c.rroth##i.dr || nesting:
estimates store block2
lrtest block1 block2
mixed giving male  c.rroth i.gr i.ir c.rroth##i.dr || nesting:
estimates store block1
mixed giving male  c.rroth i.gr i.ir i.dr || nesting:
estimates store block2
lrtest block1 block2
* Preferred model: RR is contingent in DR=2
mixed giving male  c.rroth i.gr i.ir c.rroth##i.dr || nesting:
margins dr, at(rroth=(0(1)10)) atmeans
marginsplot
* Whether there was 1 or 2 others to GR
gen rrtwo = .
recode rrtwo (.=0) if rr==1
recode rrtwo (.=1) if rr==2
gen rroth2 = .
replace rroth2 = rrsim1 if rr==1
replace rroth2 = (rrsim1+rrsim2) if rr==2
****************************************************************************************************************
****************************************************************************************************************
*** Need to add this to the results...
mixed giving male  c.rroth2##i.rrtwo i.gr i.ir i.dr || nesting:
sum rroth2 if rr==1
sum rroth2 if rr==2
mixed giving male  c.rroth2##c.rroth2 i.gr i.ir i.dr || nesting:







sum giving if dr==0 & gr==0 & ir==0 & rr==0
sum giving if dr==1 & gr==0 & ir==0 & rr==0
sum giving if dr==2 & gr==0 & ir==0 & rr==0
sum giving if dr==0 & gr==1 & ir==0 & rr==0
sum giving if dr==1 & gr==1 & ir==0 & rr==0
sum giving if dr==2 & gr==1 & ir==0 & rr==0
sum giving if dr==0 & rr==2 & gr==0 & ir==0
sum giving if dr==1 & rr==2 & gr==0 & ir==0
sum giving if dr==2 & rr==2 & gr==0 & ir==0
sum giving if dr==0 & gr==0 & ir==1 & rr==0
sum giving if dr==1 & gr==0 & ir==1 & rr==0
sum giving if dr==2 & gr==0 & ir==1 & rr==0
sum giving if dr==0 & gr==1 & ir==1 & rr==0
sum giving if dr==1 & gr==1 & ir==1 & rr==0
sum giving if dr==2 & gr==1 & ir==1 & rr==0
sum giving if dr==0 & rr==2 & gr==1 & ir==0
sum giving if dr==1 & rr==2 & gr==1 & ir==0
sum giving if dr==2 & rr==2 & gr==1 & ir==0
sum giving if dr==0 & gr==0 & ir==2 & rr==0
sum giving if dr==1 & gr==0 & ir==2 & rr==0
sum giving if dr==2 & gr==0 & ir==2 & rr==0
sum giving if dr==0 & gr==1 & ir==2 & rr==0
sum giving if dr==1 & gr==1 & ir==2 & rr==0
sum giving if dr==2 & gr==1 & ir==2 & rr==0
sum giving if dr==0 & rr==2 & gr==2 & ir==0
sum giving if dr==1 & rr==2 & gr==2 & ir==0
sum giving if dr==2 & rr==2 & gr==2 & ir==0
sum giving if dr==0 & gr==0 & ir==0 & rr==1
sum giving if dr==1 & gr==0 & ir==0 & rr==1
sum giving if dr==2 & gr==0 & ir==0 & rr==1
sum giving if dr==0 & gr==1 & ir==0 & rr==1
sum giving if dr==1 & gr==1 & ir==0 & rr==1
sum giving if dr==2 & gr==1 & ir==0 & rr==1
sum giving if dr==0 & rr==2 & gr==0 & ir==1
sum giving if dr==1 & rr==2 & gr==0 & ir==1
sum giving if dr==2 & rr==2 & gr==0 & ir==1
sum giving if dr==0 & gr==0 & ir==1 & rr==1
sum giving if dr==1 & gr==0 & ir==1 & rr==1
sum giving if dr==2 & gr==0 & ir==1 & rr==1
sum giving if dr==0 & gr==1 & ir==1 & rr==1
sum giving if dr==1 & gr==1 & ir==1 & rr==1
sum giving if dr==2 & gr==1 & ir==1 & rr==1
sum giving if dr==0 & rr==2 & gr==1 & ir==1
sum giving if dr==1 & rr==2 & gr==1 & ir==1
sum giving if dr==2 & rr==2 & gr==1 & ir==1
sum giving if dr==0 & gr==0 & ir==2 & rr==1
sum giving if dr==1 & gr==0 & ir==2 & rr==1
sum giving if dr==2 & gr==0 & ir==2 & rr==1
sum giving if dr==0 & gr==1 & ir==2 & rr==1
sum giving if dr==1 & gr==1 & ir==2 & rr==1
sum giving if dr==2 & gr==1 & ir==2 & rr==1
sum giving if dr==0 & rr==2 & gr==2 & ir==1
sum giving if dr==1 & rr==2 & gr==2 & ir==1
sum giving if dr==2 & rr==2 & gr==2 & ir==1
sum giving if dr==0 & gr==0 & ir==0 & rr==2
sum giving if dr==1 & gr==0 & ir==0 & rr==2
sum giving if dr==2 & gr==0 & ir==0 & rr==2
sum giving if dr==0 & gr==1 & ir==0 & rr==2
sum giving if dr==1 & gr==1 & ir==0 & rr==2
sum giving if dr==2 & gr==1 & ir==0 & rr==2
sum giving if dr==0 & rr==2 & gr==0 & ir==2
sum giving if dr==1 & rr==2 & gr==0 & ir==2
sum giving if dr==2 & rr==2 & gr==0 & ir==2
sum giving if dr==0 & gr==0 & ir==1 & rr==2
sum giving if dr==1 & gr==0 & ir==1 & rr==2
sum giving if dr==2 & gr==0 & ir==1 & rr==2
sum giving if dr==0 & gr==1 & ir==1 & rr==2
sum giving if dr==1 & gr==1 & ir==1 & rr==2
sum giving if dr==2 & gr==1 & ir==1 & rr==2
sum giving if dr==0 & rr==2 & gr==1 & ir==2
sum giving if dr==1 & rr==2 & gr==1 & ir==2
sum giving if dr==2 & rr==2 & gr==1 & ir==2
sum giving if dr==0 & gr==0 & ir==2 & rr==2
sum giving if dr==1 & gr==0 & ir==2 & rr==2
sum giving if dr==2 & gr==0 & ir==2 & rr==2
sum giving if dr==0 & gr==1 & ir==2 & rr==2
sum giving if dr==1 & gr==1 & ir==2 & rr==2
sum giving if dr==2 & gr==1 & ir==2 & rr==2
sum giving if dr==0 & rr==2 & gr==2 & ir==2
sum giving if dr==1 & rr==2 & gr==2 & ir==2
sum giving if dr==2 & rr==2 & gr==2 & ir==2









